# 列表的定义： [] 括号中用逗号隔开的数据 [元素，元素，元素]
# 可以存储任意类型的数据
# 列表中也可以存储列表

data01 = [ i for i in range(1,11)]
print(data01)

data02 = [ i ** 2 for i in range(1,11) if i % 2]
print(data02)

data03 = ["192.168.81.%s" % i for i in range(1,11)]
print(data03)


# 列表操作符
# 1.获取长度：len()
# 2.判断成员包含关系：in、not in
# 3.索引：[index]

data04 = ["linux","windows","macos"]
data04[2] = "nginx"
print(data04)
# 列表中的数据是可变的

# 列表对象的操作方法
# 1.append()：添加数据
data05 = ["http"]
data05.append("https")
data05.append("ftp")
data05.append("ssh")
print(data05)


# -------------------------遍历列表-------------------------

apps = ["http","https","ftp","ssh"]
for i  in apps:
    print("yum install %s -y" % i)

servers = [ ["10.1.1.1","admin",22] , ["10.1.1.2","admin",22] , ["10.1.1.3","admin",22] ]
for i,j,k in servers:
     print("ssh %s@%s -p %s" % (j,i,k))

# -------------------------遍历字符串-------------------------

# test1 = "hello world"
# for i in test1:
#     print(i)